/*
 * mark.h
 *
 *  Created on: 13.06.2011
 *      Author: nick
 */

#ifndef MARK_H_
#define MARK_H_


#include <iostream>
#include "stdio.h"
#include "bloblib/BlobResult.h"
#include <highgui.h>
#include <cxcore.h>
#include <cv.h>
#include "tracking_settings.h"


using namespace std;
using namespace cv;

struct SVec2D {
	float x;
	float y;
};

typedef enum _FloorOrientation{
	leftWall,
	rightWall,
	middle
} EOrientation;

class CMark {
public:
	//! Create a mark with the parameters of a blob
	CMark( CBlob* blob );
	//! returns the roundness of the mark
	double roundness() const;
	//! returns the area of the mark
	double area() const;
	//! movement vector
	SVec2D vector() const;
	//! centerposition of the mark
	SVec2D pos() const;
	// perimeter of the mark
	double perimeter() const;
	//! orientation of the mark
	EOrientation orientation() const;
	//! returns true if the mark has been tracked
	bool tracked() const;
	//! returns the last frame the Mark has been tracked on
	Mat lastFrame();
	//! returns true if last position has been near the border of the fov
	bool lastSeenOnBorder();

	//! draws the Markdata into it's latest frame
	void drawDataToLatestFrame();

	/*!
	 * compare another mark to this one. Returns a value
	 * that indicates the probability of
	 * the two Marks being the same.
	 */
	int equals( CMark* oldMark) const;
	//! update the content of the mark with the latest data
	void updateData(CMark* newMark, Mat frame);
	//! draw the data of the mark into a mat
	void drawDataToMat(Mat &Mat, bool textInfo) const;
	//! returns the value of the updatecounter
	int updateCounter() const;
	//! increments the updatecounter
	void incUpdateCounter();
	//! print Markdata to an fstream
	void printData() const;

private:
	//! private default CTOR
	CMark(){};
	//! roundness of the mark
	double m_roundness;
	//! area of the mark
	double m_area;
	//! perimeter of the mark
	double m_perimeter;
	//! vector of movement
	SVec2D m_vector;
	//! Position of the Mark (center)
	SVec2D m_pos;
	//! the wall on which the mark is placed on
	EOrientation m_orientation;
	//! number of iterations the mark hasn't been updated
	int m_updateCounter;
	//! true if the mark is being tracked
	bool m_tracked;
	//! latest frame the mark can be seen on
	Mat m_latestFrame;
};

string intToString(int i);

#endif /* MARK_H_ */
